package com.yantu.controller.student;

import com.yantu.bean.User;
import com.yantu.mapper.UserMapper;
import com.yantu.util.Result;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
@ApiModel("当前用户信息")
public class StudentUserCurrentController {
    @Autowired
    UserMapper userMapper;


    @GetMapping("/userCurrent/{id}")
    @ApiOperation("当前用户信息")
    public Result userCurrent(@PathVariable("id") Integer id) {

        User user = userMapper.selectById(id);

        if(user!=null){
            HashMap<String, Object> map = new HashMap<>();
            map.put("id",id);
            map.put("userName",user.getUserName());
            map.put("age",user.getAge());
            map.put("role",user.getRole());
            map.put("sex",user.getSex());
            map.put("birthDay",user.getBirthDay());
            map.put("phone",user.getPhone());
            map.put("createTime",user.getCreateTime());
            map.put("status",user.getStatus());
            map.put("userLevel",user.getUserLevel());
            map.put("classes",user.getClass());
            map.put("imagePath",user.getImagePath());


            return Result.succ(200,"查询成功",map);
        }else {
            return Result.fail("没有该用户");
        }
    }


}
